<template>
  <div class="dashboard-editor-container">

    <el-row style="background:#fff;padding:16px 16px 0;margin-bottom:32px;height:450px" >
      <pie-chart v-if ="dd" :pieTypeData="pieTypeData" :pieDataValue="pieDataValue" style="height:400px"/>
    </el-row>

  </div>
</template>

<script>
import { getPurposeChart } from "@/api/report/purposeChart";
import PieChart from '../../dashboard/PieChart'


export default {
  name: 'Index',
  components: {
    PieChart
  },
  data() {
    return {
      dd:false,
      pieDataValue:[],
      pieTypeData:[]
    }

  },
  created() {
    this.getList();
  },
  methods: {
    getList(){
        this.pieDataValue = []
        this.pieTypeData = []
        getPurposeChart().then(response => {
          response.rows.forEach(e => {
            var ss = {};
            ss.value = e.purposeCount
            ss.name = e.purposeName
            this.pieDataValue.push(ss)
            this.pieTypeData.push(e.purposeName)
            this.dd = true
          })
        })
    }
  }

}
</script>

<style lang="scss" scoped>
.dashboard-editor-container {
  padding: 32px;
  background-color: rgb(240, 242, 245);
  position: relative;

  .chart-wrapper {
    background: #fff;
    padding: 16px 16px 0;
    margin-bottom: 32px;
  }
}

@media (max-width:1024px) {
  .chart-wrapper {
    padding: 8px;
  }
}
</style>
